package SlidingWindow;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024-10-12
 * Time: 20:52
 */
class Solution2 {
    public int lengthOfLongestSubstring(String ss) {
        int left = 0 , right = 0 , ret = 0;
        char[] s = ss.toCharArray();
        int n = s.length;
        int[] hash = new int[128];
        while(right < n){
            hash[s[right]]++;
            while(hash[s[right]] > 1){
                hash[s[left++]]--;//出窗口
            }
            ret = Math.max(ret , right - left + 1);
            right++;
        }
        return ret;

    }
}
public class Test2 {
}
